﻿using System.Collections.Generic;
using System.Data;
using Model;

namespace DataAccess
{
    public class FechaDataAccess
    {
        public IList<Mes> ObtenerMeses()
        {
            var meses = new List<Mes>();

            using (IDataReader dataReader = SqlHelper.ExecuteReader(CommandType.StoredProcedure, "ObtenerMeses"))
            {
                while (dataReader.Read())
                {
                    meses.Add(new Mes { IdMes = SqlHelper.GetInt(dataReader, 0), NombreMes = SqlHelper.GetString(dataReader, 1) });
                }
                dataReader.Close();
            }
            return meses;
        }

        public IList<Anio> ObtenerAnios()
        {
            var anios = new List<Anio>();

            using (IDataReader dataReader = SqlHelper.ExecuteReader(CommandType.StoredProcedure, "ObtenerAnios"))
            {
                while (dataReader.Read())
                {
                    anios.Add(new Anio { IdAnio = SqlHelper.GetInt(dataReader, 0) } );
                }
                dataReader.Close();
            }
            return anios;
        }
    }
}

